﻿using System;
using System.Text.RegularExpressions;
using FFmpegVideoClip.Configuration;

namespace FFmpegVideoClip.Lib.Processing
{
    public interface ITaskInfo
    {
        public TimeSpan ProcessorTime { get;  set; }
        public bool IsError { get; set; }
        void SetTaskInfo(string? value)
        {
            if (string.IsNullOrWhiteSpace(value))
                return;
            if (value.StartsWith("frame="))
            {
                if (TimeSpan.TryParse(Regex.Match(value, @"(?i)(?<=time=)\S+").Value, out TimeSpan time))
                    ProcessorTime = time;
            }
            if (Config.FFmpegSuccessValidated.IsMatch(value))
            {
                IsError = false;
            }
        }
    }
}

